<!DOCTYPE html>

<html>

<head>
    <meta charset="utf-8">
    <title>产废点收集情况</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
    <link rel="stylesheet" href="../../layuiadmin/layui/css/my.css" media="all">
    </style>
</head>

<body>
    <div class="layui-form" style="margin-left:20px;margin-top:15px;margin-bottom:-20px">
        <div class="layui-form-item">
            <label class="layui-form-label">收集日期</label>
            <div class="layui-inline">
                <input type="text" class="layui-input" id="datetime" autocomplete="off" placeholder="请选择日期">
            </div>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;医院名称：
            <div class="layui-inline" style="width:300px">
                <select name="hid" id="select" style="width:300px" class="layui-input" lay-search>
                    <option value=""></option>
                </select>
            </div>
            <button class="layui-btn layui-btn-normal" data-type="reload" id="serch"><i class="layui-icon">&#xe615;</i>查询</button>
        </div>
    </div>
    <table id="demo" lay-filter="test"></table>
    <script src="../../layuiadmin/layui/layui.js"></script>
    <script src="../../layuiadmin/layui/jquery-3.3.1.min.js"></script>
    <script src="../../layuiadmin/layui/action.js"></script>
    <script>
        layui.config({
            base: '../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index'], function() {


            layui.use('laydate', function() {
                var laydate = layui.laydate;
                var form = layui.form;
                //执行一个laydate实例
                laydate.render({
                    elem: '#datetime', //指定元素
                    theme: "#1E9FFF"
                });
            });
            layui.use('form', function() {
                var form = layui.form;
                $.ajax({
                    url: "../../../Cust/hospital",
                    dataType: 'json',
                    type: "get",
                    success: function(res) {
                        $.each(res.data, function(index) {
                            var id = res.data[index].hid;
                            var name = res.data[index].name;
                            $("#select").append("<option value='" + id + "'>" + name + "</option>")
                        });
                        layui.form.render();
                    }

                })
            });


            layui.use('table', function() {
                var table = layui.table;
                var $ = layui.$;

                var tableIns = table.render({
                    elem: '#demo',
                    height: 'full-90',
                    data: [],
                    totalRow: true,
                    cols: [
                        [ //表头
                            {
                                field: 'hospname',
                                title: '医院名称',
                                width: "8%",
                                align: 'center',
                                event: "info"
                            }, {
                                field: 'custname',
                                title: '科室名称',
                                width: "8%",
                                align: 'center',
                                event: "info"
                            }, {
                                field: 'ctime',
                                title: '收集时间',
                                align: 'center',
                                width: "10%"

                            }, {
                                field: 'cname',
                                title: '收集人员',
                                align: 'center',
                                width: "7.5%"

                            }, {
                                field: 'sname',
                                title: '审核人员',
                                align: 'center',
                                totalRowText: '合计',
                                width: "7.5%"
                            }, {
                                field: 'totalweight',
                                title: '医疗废物合计',
                                width: "10%",
                                align: 'center',
                                totalRow: true,
                                templet: function(d) {
                                    return parseFloat(isZero(d.totalweight)).toFixed(2);
                                }
                            }, {
                                field: 'weight_0',
                                title: '感染性',
                                width: "7%",
                                align: 'center',
                                totalRow: true,
                                templet: function(d) {
                                    return parseFloat(isZero(d.weight_0)).toFixed(2);
                                }
                            }, {
                                field: 'weight_1',
                                title: '损伤性',
                                width: "7%",
                                align: 'center',
                                totalRow: true,
                                templet: function(d) {
                                    return parseFloat(isZero(d.weight_1)).toFixed(2);

                                }
                            }, {
                                field: 'weight_5',
                                title: '病理性',
                                width: "7%",
                                align: 'center',
                                totalRow: true,
                                templet: function(d) {
                                    return parseFloat(isZero(d.weight_5)).toFixed(2);

                                }
                            }, {
                                field: 'weight_4',
                                title: '药物性',
                                width: "7%",
                                align: 'center',
                                totalRow: true,
                                templet: function(d) {
                                    return parseFloat(isZero(d.weight_4)).toFixed(2);

                                }
                            }, {
                                field: 'weight_3',
                                title: '化学性',
                                width: "7%",
                                align: 'center',
                                totalRow: true,
                                templet: function(d) {
                                    return parseFloat(isZero(d.weight_3)).toFixed(2);

                                }
                            }, {
                                field: 'weight_2',
                                title: '输液瓶',
                                width: "7%",
                                align: 'center',
                                totalRow: true,
                                templet: function(d) {
                                    return parseFloat(isZero(d.weight_2)).toFixed(2);

                                }
                            }, {
                                field: 'weight_7',
                                title: '输液袋',
                                width: "7%",
                                align: 'center',
                                totalRow: true,
                                templet: function(d) {
                                    return parseFloat(isZero(d.weight_7)).toFixed(2);

                                }
                            }
                        ]
                    ],
                    skin: 'row', //表格风格				
                    even: true,
                });
                table.on('rowDouble(test)', function(obj) {
                    var d = obj.data;
                    layer.open({
                        type: 2,
                        area: area(1030, 960),
                        offset: 'auto',
                        maxmin: true,
                        title: ['详细信息', 'background:#1E9FFF;color:white;font-size:17px;font-weight:bold'],
                        content: 'information/collinfo.html',
                        success: function(layero, index) {
                            var body = layer.getChildFrame('body', index);
                            body.find('#custname').html(d.custname);
                            body.find('#cid').val(d.cid);
                            body.find('#ctime').html(d.ctime);
                            body.find('#cname').html(d.cname);
                            body.find('#sname').html(d.sname);
                            body.find('#weight_0').html(parseFloat(isZero(d.weight_0)).toFixed(2) + " 公斤"); //感染性
                            body.find('#weight_1').html(parseFloat(isZero(d.weight_1)).toFixed(2) + " 公斤"); //损伤性
                            body.find('#weight_2').html(parseFloat(isZero(d.weight_2)).toFixed(2) + " 公斤"); //输液瓶
                            body.find('#weight_3').html(parseFloat(isZero(d.weight_3)).toFixed(2) + " 公斤"); //化学性
                            body.find('#weight_4').html(parseFloat(isZero(d.weight_4)).toFixed(2) + " 公斤"); //药物性
                            body.find('#weight_5').html(parseFloat(isZero(d.weight_5)).toFixed(2) + " 公斤"); //病理性
                            body.find('#weight_7').html(parseFloat(isZero(d.weight_7).toFixed(2)) + " 公斤"); //病理性
                            body.find('#num_0').html(d.num_0 + " 箱");
                            body.find('#num_1').html(d.num_1 + " 箱");
                            body.find('#num_2').html(d.num_2 + " 袋");
                            body.find('#num_5').html(d.num_5 + " 箱");
                            body.find('#num_4').html(d.num_4 + " 箱");
                            body.find('#num_3').html(d.num_3 + " 袋");
                            body.find('#num_7').html(d.num_7 + " 袋");
                            body.find('#nval1_2').html(d.nval1_2 + " 只");
                            body.find('#nval1_5').html(d.nval1_5 + " 只");
                            body.find('#total').html(d.total + " 箱");
                            body.find('#totalweight').html(parseFloat(d.totalweight).toFixed(2) + " 公斤");
                        }
                    });
                });
                table.on('tool(test)', function(obj) {
                    var d = obj.data;
                    if (obj.event === 'info') {
                        layer.open({
                            type: 2,
                            area: area(1030, 960),
                            offset: 'auto',
                            maxmin: true,
                            title: ['详细信息', 'background:#1E9FFF;color:white;font-size:17px;font-weight:bold'],
                            content: 'information/collinfo.html',
                            success: function(layero, index) {
                                var body = layer.getChildFrame('body', index);
                                body.find('#custname').html(d.custname);
                                body.find('#cid').val(d.cid);
                                body.find('#ctime').html(d.ctime);
                                body.find('#cname').html(d.cname);
                                body.find('#sname').html(d.sname);
                                body.find('#weight_0').html(parseFloat(isZero(d.weight_0)).toFixed(2) + " 公斤"); //感染性
                                body.find('#weight_1').html(parseFloat(isZero(d.weight_1)).toFixed(2) + " 公斤"); //损伤性
                                body.find('#weight_2').html(parseFloat(isZero(d.weight_2)).toFixed(2) + " 公斤"); //输液瓶
                                body.find('#weight_3').html(parseFloat(isZero(d.weight_3)).toFixed(2) + " 公斤"); //化学性
                                body.find('#weight_4').html(parseFloat(isZero(d.weight_4)).toFixed(2) + " 公斤"); //药物性
                                body.find('#weight_5').html(parseFloat(isZero(d.weight_5)).toFixed(2) + " 公斤"); //病理性
                                body.find('#weight_7').html(parseFloat(isZero(d.weight_7).toFixed(2)) + " 公斤"); //病理性
                                body.find('#num_0').html(d.num_0 + " 箱");
                                body.find('#num_1').html(d.num_1 + " 箱");
                                body.find('#num_2').html(d.num_2 + " 袋");
                                body.find('#num_5').html(d.num_5 + " 箱");
                                body.find('#num_4').html(d.num_4 + " 箱");
                                body.find('#num_3').html(d.num_3 + " 袋");
                                body.find('#num_7').html(d.num_7 + " 袋");
                                body.find('#nval1_2').html(d.nval1_2 + " 只");
                                body.find('#nval1_5').html(d.nval1_5 + " 只");
                                body.find('#total').html(d.total + " 箱");
                                body.find('#totalweight').html(parseFloat(d.totalweight).toFixed(2) + " 公斤");
                            }
                        })
                    }
                });
                $("#serch").on('click', function() {
                    tableIns.reload({
                        url: '../../../Collect/hcustcollect',
                        where: {
                            date: $("#datetime").val(),
                            hid: $("#select option:selected").val()
                        } //设定异步数据接口的额外参数

                    });
                });
            });
        });
    </script>
</body>

</html>